package com.hjy.scheduled.mysql.controller;

import com.hjy.scheduled.mysql.repository.quartzRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.hjy.scheduled.mysql.entity.quartz;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class quartzController {

    @Autowired
    private quartzRepository quartzrepository;

    @PostMapping(value = "/findall")
    @ResponseBody
    public List get(){
        return quartzrepository.findAll();
    }

    @PostMapping(value = "/save")
    @ResponseBody
    public quartz save(String name,short type,String cron){
        quartz q = new quartz();
        q.setName(name);
        q.setType(type);
        q.setCron(cron);
        return quartzrepository.save(q);
    }
}
